import Vue from 'Vue'
import DragItem from './drag-item.vue'

const DragItemConstructor = Vue.extend(DragItem)

let getDragInstance = () => {
  return new DragItemConstructor({
    el: document.createElement('div')
  })
}

let Drag = (option = {
    startPos: {
      x,y
    },
    row: {},
    onDragUp: (e) => {}
  }) => {
  let instance = getDragInstance()
  instance.startPos = option.startPos
  instance.row = option.row
  instance.onDragUp = option.onDragUp
  document.body.appendChild(instance.$el)
  Promise.resolve().then(() => {
    instance.setPosition(option.startPos.x,option.startPos.y)
  })
  return instance
}

export default Drag
